package cn.jiedh.app.meiweidk.web.webhandle;

import android.content.Context;
import android.support.v4.app.Fragment;

import com.google.gson.GsonBuilder;
import cn.jiedh.app.meiweidk.Utils.event.EventUtils;
import cn.jiedh.app.meiweidk.Utils.tool.L;
import cn.jiedh.app.meiweidk.web.webkit.WJBridgeHandler;
import cn.jiedh.app.meiweidk.web.webkit.WJCallbacks;

/**
 * @name：
 * @author： liuyun
 * @phone： 15723310658
 * @createTime： 2017/12/14
 * @modifyTime： 2017/12/14
 * @explain：说明
 */


public class ShareHandle implements WJBridgeHandler {
    public static final String HANDLE_NAME="share";
    private Context mCox;
    private Fragment mFragment;

    public ShareHandle(Context mCox) {
        this.mCox = mCox;
    }

    public ShareHandle(Fragment mFragment) {
        this.mFragment = mFragment;
    }

    @Override
    public void handler(String data, WJCallbacks callbacks) {
        if(L.isDebug) {
            System.out.println("ShareHandle-----------------------------------------------------------------------------");
            System.out.println("data-->" + data);
        }
        ShareBean bean=null;
        try {
            bean= new GsonBuilder().create().fromJson(data,ShareBean.class);
            EventUtils.getDefault().forward(bean);

        }catch (Exception e){
            if(L.isDebug){
                L.e("解析异常");
                e.printStackTrace();
            }
            return;
        }
    }
}
